/*     */ package com.qmsk.business.member.incomeType.controller;
/*     */ 
/*     */ import com.qmsk.business.bussBill.pbPaid.PbPaid;
/*     */ import com.qmsk.business.member.incomeType.dao.IncomeTypeDAO;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/incomeType"})
/*     */ public class IncomeTypeController
/*     */ {
/*  33 */   private static final Logger logger = Logger.getLogger(IncomeTypeController.class);
/*     */ 
/*     */   @Autowired
/*     */   private IncomeTypeDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  51 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  53 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, null, nPageIdx, nPageSize);
/*  54 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  56 */       logger.error(e);
/*  57 */       ResponseUtils.setErrorMsgResponse(
/*  58 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/stId/{stId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListStId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("stId") Integer stId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  75 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  77 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, stId, nPageIdx, nPageSize);
/*  78 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  80 */       logger.error(e);
/*  81 */       ResponseUtils.setErrorMsgResponse(
/*  82 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/act/{action}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAction(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("action") String ctrlName, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  99 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try
/*     */     {
/* 102 */       Integer stId = null;
/* 103 */       if (ctrlName != null) {
/* 104 */         stId = Integer.valueOf(PbPaid.getStOfId(ctrlName));
/*     */       }
/* 106 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, stId, nPageIdx, nPageSize);
/* 107 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 109 */       logger.error(e);
/* 110 */       ResponseUtils.setErrorMsgResponse(
/* 111 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 127 */     String sGsonInData = RequestUtils.getString(request, "data");
/*     */     try {
/* 129 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/* 130 */       DbConnection.commit();
/* 131 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 132 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 133 */         response);
/*     */     } catch (Exception e) {
/* 135 */       DbConnection.rollback();
/* 136 */       logger.error(e);
/* 137 */       ResponseUtils.setErrorMsgResponse(
/* 138 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 139 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 155 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 157 */       String[] strParams = id.split(",");
/* 158 */       int nResult = this.dao.deleteParams(strParams);
/* 159 */       DbConnection.commit();
/* 160 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 161 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 162 */         response);
/*     */     } catch (Exception e) {
/* 164 */       DbConnection.rollback();
/* 165 */       logger.error(e);
/* 166 */       ResponseUtils.setErrorMsgResponse(
/* 167 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 168 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 184 */     String id = request.getParameter("id");
/* 185 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 187 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 188 */       if (g == null) {
/* 189 */         ResponseUtils.setErrorMsgResponse(
/* 190 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 191 */           response);
/* 192 */         return; }
/* 193 */       int nResult = this.dao.updateJsonOneRow(g, id);
/* 194 */       DbConnection.commit();
/* 195 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 196 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 197 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 200 */       DbConnection.rollback();
/* 201 */       logger.error(e);
/* 202 */       ResponseUtils.setErrorMsgResponse(
/* 203 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 204 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.incomeType.controller.IncomeTypeController
 * JD-Core Version:    0.5.3
 */